package com.sls.game.dao.maxshu.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.maxshu.MaxshuAsDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.maxshu.MaxshuAreaServer;

@Repository("maxshuAsDAO")
public class MaxshuAsDAOImpl extends SuperDAO<MaxshuAreaServer> implements
		MaxshuAsDAO {

	@Override
	public void insertAreaServer(MaxshuAreaServer as) {
		this.getSqlSession().insert(
				"mybatis.xml.MaxshuAreaServerMapper.insert", as);

	}

	@Override
	public List<MaxshuAreaServer> queryByProIdAndASName(MaxshuAreaServer as) {
		return this
				.getSqlSession()
				.selectList(
						"mybatis.xml.MaxshuAreaServerMapper.queryByProIdAndASName",
						as);
	}

	@Override
	public Pagination<MaxshuAreaServer> queryPage(MaxshuAreaServer as) {
		Pagination<MaxshuAreaServer> paginationList = null;
		Integer rowCount = queryRowCount(as);
		as.calculate();
		List<MaxshuAreaServer> list = queryASList(as);
		paginationList = this.queryPagination(rowCount, list, as);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(MaxshuAreaServer as) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.MaxshuAreaServerMapper.queryRowCount", as);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<MaxshuAreaServer> queryASList(MaxshuAreaServer as) {
		List<MaxshuAreaServer> list = this.getSqlSession().selectList(
				"mybatis.xml.MaxshuAreaServerMapper.queryMaxshuASInfoList",
				as);
		return list;
	}

	@Override
	public List<MaxshuAreaServer> queryByProductId(String productId) {
		List<MaxshuAreaServer> list = this.getSqlSession().selectList(
				"mybatis.xml.MaxshuAreaServerMapper.queryByProductId",
				productId);
		return list;
	}

	@Override
	public List<String> queryAreaNameByProductId(String productId) {
		List<String> list = this.getSqlSession().selectList(
				"mybatis.xml.MaxshuAreaServerMapper.queryAreaNameByProductId",
				productId);
		return list;
	}

	@Override
	public void deleteByProductId(String productId) {
		this.getSqlSession().delete(
				"mybatis.xml.MaxshuAreaServerMapper.deleteByProductId",
				productId);
	}

}
